package com.example.lanouhn.firstapp.activity.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.lanouhn.firstapp.R;
import com.example.lanouhn.firstapp.activity.model.Classify;
import com.example.lanouhn.firstapp.activity.model.NappyPants;

import java.util.List;

/**
 * 分类下的二级  item 的数据解析专用的适配器
 * 纸尿裤  奶粉   等等的适配器
 * Created by lanouhn on 16/7/19.
 */
public class ClassifyNappyAdapter extends BaseAdapter {
    //定义数组及上下文
    private List<Classify> list;
    private Context context;

    public ClassifyNappyAdapter(List<Classify> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder holder = null;
        if (view == null) {
            //View view = View.inflate(context, R.layout.notes_item,null);
            holder = new ViewHolder();
            view = LayoutInflater.from(context).inflate(R.layout.item_classify_nappy, null);

            holder.gc_name = (TextView) view.findViewById(R.id.gc_name);
//            holder.name= (TextView) view.findViewById(R.id.classify_textView);

            view.setTag(holder);
        }else {
            holder = (ViewHolder)view.getTag();
        }
        Classify classify = list.get(i);
        holder.gc_name.setText( classify.getGc_name());
        return view;
    }
        class ViewHolder {
            private TextView gc_name;
        }
}




